package com.wctj.api.business.cmb.service.impl;

import com.wctj.api.base.response.Response;
import com.wctj.api.base.utils.JacksonUtil;
import com.wctj.api.base.utils.JsonUtils;
import com.wctj.api.business.cmb.bean.CmbPayBean;
import com.wctj.api.business.cmb.request.CmbMidRequest;
import com.wctj.api.business.cmb.request.CmbPayParams;
import com.wctj.api.business.cmb.request.CmbSubAccountRequest;
import com.wctj.api.business.cmb.request.Ntqacinfx;
import com.wctj.api.business.cmb.service.CmbpayService;
import com.wctj.api.business.common.dto.DdwxMemberSubAccountDTO;
import com.wctj.api.business.common.service.AbstractPayManagerService;
import com.wctj.api.business.common.service.DdwxMemberSubAccountService;
import com.wctj.api.infra.cmb.DcHelper;
import com.wctj.api.infra.cmb.VerifySigDemo;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.security.Security;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;

@Slf4j
@Service
public class CmbPayServiceImpl extends AbstractPayManagerService implements CmbpayService {

    private static final int BOUND_START = 1000000;
    private static final int BOUND_END = 9000000;
    private static Random random = new Random();

    @Autowired
    private CmbPayBean cmbPayBean;

    @Autowired
    private DdwxMemberSubAccountService ddwxMemberSubAccountService;

    @Override
    public Response ntdmaAdd(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "NTDMAADD";

            JSONObject bodyObj = new JSONObject();
            JSONArray ntbusmody = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("busmod", "S300F");
            ntbusmody.put(aaa);
            bodyObj.put("ntbusmody", ntbusmody);

            JSONArray ntdmaaddx = new JSONArray();
            JSONObject bbb = new JSONObject();
            bbb.put("accnbr", params.getAccnbr());
            bbb.put("dmanbr", params.getDmanbr());
            bbb.put("dmanam", params.getDmanam());
            bbb.put("yurref", params.getYurref());
            bbb.put("BALLMT", "");
            bbb.put("LMTFLG", "N");
            ntdmaaddx.put(bbb);
            bodyObj.put("ntdmaaddx", ntdmaaddx);

            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
        /**
         * {
         *     "response": {
         *         "body": {
         *             "ntdmabadz1": [
         *                 {
         *                     "dmanbr": "00032",
         *                     "errcod": "SUC0000",
         *                     "rtnsts": "S"
         *                 }
         *             ]
         *         },
         *         "head": {
         *             "bizcode": "",
         *             "funcode": "NTDMAADD",
         *             "reqid": "202303081109213621dev",
         *             "resultcode": "SUC0000",
         *             "resultmsg": "",
         *             "rspid": "202303081109213890001cdcserver-67fdb66b6c-5mrrh",
         *             "userid": "N003716657"
         *         }
         *     }
         * }
         */
    }

    @Override
    public Response ntdmLST(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "NTDMALST";

            JSONObject bodyObj = new JSONObject();
            JSONArray ntdmalstx = new JSONArray();
            JSONObject bbb = new JSONObject();
            bbb.put("accnbr", params.getAccnbr());
            bbb.put("dmanbr", params.getDmanbr());
            bbb.put("rsv50z", params.getRsv50z());
            ntdmalstx.put(bbb);
            bodyObj.put("ntdmalstx", ntdmalstx);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }


    /**
     * 封装 请求信息
     *
     * @param bodyObj 请求体
     * @return
     */
    public String GenerateRequestBody(JSONObject bodyObj, String funcode) {
        try {
            // 装载BC库,必须在应用的启动类中调用此函数
            Security.addProvider(new BouncyCastleProvider());
            System.setProperty("sun.net.http.retryPost", "false");

            // 准备接口数据，生产请替换为具体接口请求报文,包含所需的请求字段
            String currentDatetime = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
            String reqid = new SimpleDateFormat("yyyyMMddHHmmssSSSS").format(new Date()) + (BOUND_START + random.nextInt(BOUND_END));

            JSONObject sendRequestObj = new JSONObject();
            JSONObject requestObj = new JSONObject();
            JSONObject headObj = new JSONObject();
            JSONObject signatureObj = new JSONObject();

            headObj.put("funcode", funcode); // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            headObj.put("userid", cmbPayBean.getUid());
            headObj.put("reqid", reqid);

            /**
             * 对接招行请求报文先预添加signature内容，包含sigtim和sigdat两个KEY，sigtim为当前时间（年月日时分秒，24小时制），
             * 服务器验签时会和当前时间比较，如果前后相差一个小时会报错，sigdat先预填充"__signature_sigdat__"
             */
            signatureObj.put("sigdat", "__signature_sigdat__");
            signatureObj.put("sigtim", currentDatetime);

            requestObj.put("head", headObj);
            requestObj.put("body", bodyObj);

            sendRequestObj.put("request", requestObj);
            sendRequestObj.put("signature", signatureObj);
            return sendRequestObj.toString();
        } catch (Exception e) {
            log.error("CmbPayServiceImpl error", e);
            return null;
        }
    }


    @Override
    public Response ntdmaDLT(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "NTDMADLT";

            JSONObject bodyObj = new JSONObject();
            JSONArray ntbusmody = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("busmod", "S4005");
            ntbusmody.put(aaa);
            bodyObj.put("ntbusmody", ntbusmody);

            JSONArray ntdmadltx1 = new JSONArray();
            JSONObject bbb = new JSONObject();
            bbb.put("accnbr", params.getAccnbr());
            bbb.put("yurref", params.getYurref());
            ntdmadltx1.put(bbb);
            bodyObj.put("ntdmadltx1", ntdmadltx1);

            JSONArray ntdmadltx2 = new JSONArray();
            JSONObject ccc = new JSONObject();
            ccc.put("dmanbr", params.getDmanbr());
            ntdmadltx2.put(ccc);
            bodyObj.put("ntdmaaddx", ntdmadltx2);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response proactivelyNotify(Map notifyRequest) {
        try {
            log.info("接受招行主动通知消息=================" + notifyRequest.toString());
            //先将通知内容解密  验签
            //签名信息为报文中sigdat值的内容，先取出sigdat里面的内容待后面验签用，然后用“__signature_sigdat__”替换掉sigdat的值
            String resSign = (String) notifyRequest.get("sigdat");
            notifyRequest.put("sigdat", "__signature_sigdat__");
            //银行的公钥对上面的内容进行验签，验签算法为国密SM2，获取验签结果
            String bankPubkey = cmbPayBean.getBankPubkey();
            //JSONObject json= (JSONObject) JSONObject.toJSON(notifyRequest);
            //JSONObject json = JsonUtils.convertValue(notifyRequest.toString(), JSONObject.class);
            //System.out.println(json.toString());
            boolean b = VerifySigDemo.cmbSM2Verify(bankPubkey, JacksonUtil.getNormalPatternJsonString(notifyRequest), resSign);
            //System.out.println(b);
            /*String nottyp = notifyRequest.getNottyp();
            if (nottyp.equals("YQN01010")){ //账务变动通知
                JSONObject jsonObject = JSONObject.parseObject(notifyRequest.getNotdat());
                BigDecimal trsAmt = jsonObject.getBigDecimal("trsAmt");
                String dumNbr = jsonObject.getString("dumNbr");
                //addRecharge(dumNbr,trsAmt.toString());
            }*/
        } catch (Exception e) {
            return new Response().failure(e.getMessage());
        }
        return new Response().data("接收通知成功!");
    }

    @Override
    public Response cdcMatchCardBin(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "CdcMatchCardBin";

            JSONObject bodyObj = new JSONObject();
            JSONArray CdcMatchCardBinX1 = new JSONArray();

            List<String> accNbrList = params.getAccNbrList();
            for (String accNbrStr : accNbrList) {
                JSONObject aaa = new JSONObject();
                aaa.put("accNbr", accNbrStr);
                aaa.put("rsv50z", params.getRsv50z());
                CdcMatchCardBinX1.put(aaa);
            }
            bodyObj.put("CdcMatchCardBinX1", CdcMatchCardBinX1);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response BB6BTHHL(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "BB6BTHHL";

            JSONObject bodyObj = new JSONObject();
            JSONArray bb6busmod = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("buscod", "N03020"); // N03010-代发工资       N03020-代发其他     N03040-钱包代发（从钱包出款，选择此业务时，结算通道赋值W）
            aaa.put("busmod", "S3019");
            aaa.put("rsv50z", params.getRsv50z());
            bb6busmod.put(aaa);
            bodyObj.put("bb6busmod", bb6busmod);

            JSONArray bb6cdcbhx1 = new JSONArray();
            JSONObject bbb = new JSONObject();
            bbb.put("begtag", "Y");
            bbb.put("endtag", "Y");

            bbb.put("accnam", params.getAccnam());
            bbb.put("accnbr", params.getAccnbr());
            bbb.put("ttlamt", params.getTtlamt());
            bbb.put("ttlcnt", params.getTtlcnt());
            bbb.put("ttlnum", params.getTtlnum());

            bbb.put("curamt", params.getCuramt());
            bbb.put("curcnt", params.getCurcnt());
            bbb.put("ccynbr", params.getCcynbr());
            bbb.put("ntfinf", params.getNtfinf());
            bbb.put("trstyp", params.getTrstyp());

            bbb.put("nusage", params.getNusAge());
            bbb.put("eptdat", params.getEptdat());
            bbb.put("epttim", params.getEpttim());
            bbb.put("yurref", params.getYurref());
            bbb.put("chlflg", params.getChlflg());
            bb6cdcbhx1.put(bbb);
            bodyObj.put("bb6cdcbhx1", bb6cdcbhx1);
            /**
             *  "bb6cdcbhx1": [
             *                 {
             *                     "accnam": "苏嘉莉",
             *                     "accnbr": "755916369410302",
             *                     "ttlamt": "2",
             *                     "ttlcnt": "1",
             *                     "ttlnum": "1",
             *
             *                     "curamt": "2",
             *                     "curcnt": "1",
             *                     "ccynbr": "10",
             *                     "ntfinf": "SMS test",
             *                     "trstyp": "BYSA",
             *
             *                     "nusage": "新云直联",
             *                     "eptdat": "20210831",
             *                     "epttim": "120001",
             *                     "yurref": "20210831000001",
             *                     "chlflg": "Y"
             *                 }
             *             ],
             */

            JSONArray bb6cdcdlx1 = new JSONArray();
            List<Ntqacinfx> ntqacinfxList = params.getNtqacinfxList();
            for (Ntqacinfx ntqacinfx : ntqacinfxList) {
                JSONObject ccc = new JSONObject();
                ccc.put("trxseq", ntqacinfx.getTrxseq());
                ccc.put("accnbr", ntqacinfx.getAccnbr());
                ccc.put("accnam", ntqacinfx.getAccnam());
                ccc.put("trsamt", ntqacinfx.getTrsamt());
                ccc.put("eacbnk", ntqacinfx.getEacbnk());
                ccc.put("eaccty", ntqacinfx.getEaccty());
                bb6cdcdlx1.put(ccc);
            }
            bodyObj.put("bb6cdcdlx1", bb6cdcdlx1);
            /**
             * "bb6cdcdlx1": [
             *                 {
             *                     "trxseq": "00000001",
             *                     "accnbr": "6226095510042141",
             *                     "accnam": "苏嘉莉",
             *                     "trsamt": "2",
             *                     "eacbnk": "755",
             *                     "eaccty": "CHN"
             *                 }
             *             ],
             */


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response BB6BTHQY(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "BB6BTHQY";

            JSONObject bodyObj = new JSONObject();
            JSONArray bb6bthqyy1 = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("buscod", params.getBuscod()); //N03010-代发工资    N03020-代发    N03040-钱包代发
            aaa.put("yurref", params.getYurref());
            aaa.put("bgndat", params.getBgndat());
            aaa.put("enddat", params.getEnddat());
            aaa.put("dattyp", params.getDattyp()); //A：经办日期；  B：期望日期；
            aaa.put("cntkey", params.getCntkey());
            aaa.put("rsv50z", params.getRsv50z());
            bb6bthqyy1.put(aaa);
            bodyObj.put("bb6bthqyy1", bb6bthqyy1);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response BB6DTLQY(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "BB6DTLQY";

            JSONObject bodyObj = new JSONObject();
            JSONArray bb6dtlqyy1 = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("reqnbr", params.getReqnbr());
            aaa.put("bthnbr", params.getBthNbr());
            aaa.put("trxseq", params.getTrxseq());
            aaa.put("histag", params.getHistag());
            aaa.put("rsv50z", params.getRsv50z());
            bb6dtlqyy1.put(aaa);
            bodyObj.put("bb6dtlqyy1", bb6dtlqyy1);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response DCAGPPDF(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "DCAGPPDF";

            JSONObject bodyObj = new JSONObject();
            bodyObj.put("payeac", params.getPayeac());
            bodyObj.put("begdat", params.getBegdat());
            bodyObj.put("enddat", params.getEnddat());
            bodyObj.put("buscod", params.getBuscod()); //代发工资:N03010,其他：N03020
            bodyObj.put("busmod", params.getBusmod()); //对应业务类型的业务模式，查询的账号需要在该业务模式的可经办账号列表里面
            bodyObj.put("eacnam", params.getEacnam());
            bodyObj.put("eacnbr", params.getEacnbr());
            bodyObj.put("ptyref", params.getPtyref());
            bodyObj.put("trxsrl", params.getTrxsrl());
            bodyObj.put("minamt", params.getMinamt());
            bodyObj.put("maxamt", params.getMaxamt());
            bodyObj.put("prtmod", params.getPrtmod()); //S：逐笔打印：每笔明细生成一个PDF文件      M：批量打印：所有明细生成生成到一个PDF文件里面
            bodyObj.put("begidx", params.getBegidx());
            bodyObj.put("pagsiz", params.getPagsiz()); //默认1000，最大限制1000，打印模式为M时表示一个文件里面包含的明细的条数，打印模式为S时表示一次可以查询明细的条数。
            bodyObj.put("cntkey", params.getCntkey()); //首次查询为空，当返回报文里面有cntkey返回时表明需要续传，请将返回报文中的cntkey值放入该字段继续请求


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response DCTASKID(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "DCTASKID";

            JSONObject bodyObj = new JSONObject();
            bodyObj.put("taskid", params.getTaskid());
            bodyObj.put("qwenab", params.getQwenab());


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response BB1PAYOP(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "BB1PAYOP";

            JSONObject bodyObj = new JSONObject();
            JSONArray bb1paybmx1 = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("busMod", "S301A");
            aaa.put("busCod", "N02030");
            bb1paybmx1.put(aaa);
            bodyObj.put("bb1paybmx1", bb1paybmx1);

            JSONArray bb1payopx1 = new JSONArray();
            JSONObject bbb = new JSONObject();
            bbb.put("ccyNbr", "10");
            bbb.put("crtAcc", params.getCrtAcc());
            bbb.put("crtNam", params.getCrtNam());
            bbb.put("crtBnk", params.getCrtBnk());
            bbb.put("crtAdr", params.getCrtAdr());
            bbb.put("brdNbr", params.getBrdNbr());
            bbb.put("dbtAcc", params.getDbtAcc());
            bbb.put("nusAge", params.getNusAge());
            bbb.put("bnkFlg", params.getBnkFlg());
            bbb.put("trsAmt", params.getTrsAmt());
            bbb.put("yurRef", params.getYurref());
            bb1payopx1.put(bbb);
            bodyObj.put("bb1payopx1", bb1payopx1);
            /**
             *  "bb1payopx1": [
             *                 {
             *                     "ccyNbr": "10",
             *                     "crtAcc": "755903332110404",
             *                     "crtNam": "欧弟专属测试户05",
             *                     "dbtAcc": "769900135910504",
             *                     "nusAge": "用途",
             *                     "bnkFlg": "Y",
             * 	                  "trsAmt": "1.05",
             *                     "yurRef": "202008260078000033"
             *                 }
             *             ]
             */

            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response BB1PAYQR(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "BB1PAYQR";

            JSONObject bodyObj = new JSONObject();
            JSONArray bb1payqrx1 = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("busCod", params.getBuscod());
            aaa.put("yurRef", params.getYurref());
            bb1payqrx1.put(aaa);
            bodyObj.put("bb1payqrx1", bb1payqrx1);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response BB1PAYBH(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "BB1PAYBH";

            JSONObject bodyObj = new JSONObject();
            JSONArray bb1bmdbhx1 = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("busMod", "S301A");
            aaa.put("busCod", "N02030");
            aaa.put("bthNbr", params.getBthNbr());
            aaa.put("dtlNbr", params.getDtlNbr());
            aaa.put("ctnFlg", params.getCtnFlg());
            aaa.put("ctnSts", params.getCtnSts());
            bb1bmdbhx1.put(aaa);
            bodyObj.put("bb1bmdbhx1", bb1bmdbhx1);

            JSONArray bb1paybhx1 = new JSONArray();

            List<Ntqacinfx> ntqacinfxList = params.getNtqacinfxList();
            for (Ntqacinfx ntqacinfx : ntqacinfxList) {
                JSONObject ccc = new JSONObject();
                ccc.put("ccyNbr", ntqacinfx.getCcynbr());
                ccc.put("crtAcc", ntqacinfx.getCrtAcc());
                ccc.put("crtNam", ntqacinfx.getCrtNam());
                ccc.put("dbtAcc", ntqacinfx.getDbtAcc());
                ccc.put("nusAge", ntqacinfx.getNusAge());
                ccc.put("bnkFlg", ntqacinfx.getBnkFlg());
                ccc.put("trsAmt", ntqacinfx.getTrsamt());
                ccc.put("yurRef", ntqacinfx.getYurRef());
                bb1paybhx1.put(ccc);
            }
            bodyObj.put("bb1paybhx1", bb1paybhx1);
            /**
             *                     "ccyNbr": "10",
             *                     "crtAcc": "755936043510703",
             *                     "crtNam": "银企直连专用测试企业251",
             *                     "dbtAcc": "755936048510901",
             *                     "nusAge": "批量支付经办测试1",
             *                     "bnkFlg": "Y",
             *                     "trsAmt": "3.00",
             *                     "yurRef": "202203311036000037"
             */


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response BB1QRYBT(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "BB1QRYBT";

            JSONObject bodyObj = new JSONObject();
            JSONArray bb1qrybtx1 = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("begDat", params.getBegdat());
            aaa.put("endDat", params.getEnddat());
            aaa.put("autStr", params.getAutstr());
            aaa.put("rtnStr", params.getRtnstr());
            bb1qrybtx1.put(aaa);
            bodyObj.put("bb1qrybtx1", bb1qrybtx1);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response BB1QRYBD(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "BB1QRYBD";

            JSONObject bodyObj = new JSONObject();
            JSONArray bb1qrybdy1 = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("bthNbr", params.getBthNbr());
            aaa.put("autStr", params.getAutstr());
            aaa.put("rtnStr", params.getRtnstr());
            aaa.put("ctnKey", params.getCtnkey());
            bb1qrybdy1.put(aaa);
            bodyObj.put("bb1qrybdy1", bb1qrybdy1);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }


    @Override
    public Response NTNSTQRY1(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "NTNSTQRY1";

            JSONObject bodyObj = new JSONObject();
            JSONArray ntnstqryx = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("eacnbr", params.getEacnbr());
            aaa.put("busmod", params.getBusmod());
            aaa.put("yermth", params.getYermth());
            aaa.put("endmth", params.getEndmth());
            aaa.put("cntflg", params.getCntflg());
            ntnstqryx.put(aaa);
            bodyObj.put("ntnstqryx", ntnstqryx);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response NTNSTLST(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "NTNSTLST";

            JSONObject bodyObj = new JSONObject();
            JSONArray ntnstwacy = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("bgndat", params.getBgndat());
            aaa.put("enddat", params.getEnddat());
            aaa.put("yermth", params.getYermth());
            aaa.put("oprlgn", params.getOprlgn());
            aaa.put("autstr", params.getAutstr());
            aaa.put("rtnstr", params.getRtnstr());
            aaa.put("ctnkey", params.getCtnkey());
            ntnstwacy.put(aaa);
            bodyObj.put("ntnstwacy", ntnstwacy);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response NTNSTQRY2(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "NTNSTQRY2";

            JSONObject bodyObj = new JSONObject();
            JSONArray ntnstqryx = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("reqnbr", params.getReqnbr());
            aaa.put("eacnbr", params.getEacnbr());
            aaa.put("yermth", params.getYermth());
            aaa.put("endmth", params.getEndmth());
            aaa.put("cntflg", params.getCntflg());
            ntnstqryx.put(aaa);
            bodyObj.put("ntnstqryx", ntnstqryx);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response NTQACINF(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "NTQACINF";

            JSONObject bodyObj = new JSONObject();
            JSONArray ntqacinfxAry = new JSONArray();
            List<Ntqacinfx> ntqacinfxList = params.getNtqacinfxList();
            for (Ntqacinfx ntqacinfx : ntqacinfxList) {
                JSONObject aaa = new JSONObject();
                aaa.put("bbknbr", ntqacinfx.getBbknbr());
                aaa.put("accnbr", ntqacinfx.getAccnbr());
                aaa.put("ccynbr", ntqacinfx.getCcynbr());
                ntqacinfxAry.put(aaa);
            }
            bodyObj.put("ntqacinfx", ntqacinfxAry);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response trsQryByBreakPoint(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "trsQryByBreakPoint";

            JSONObject bodyObj = new JSONObject();
            JSONArray TRANSQUERYBYBREAKPOINT_X1 = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("cardNbr", params.getCardNbr());
            aaa.put("beginDate", params.getBeginDate());
            aaa.put("transactionSequence", params.getTransactionSequence());
            aaa.put("endDate", params.getEndDate());
            aaa.put("queryAcctNbr", params.getQueryAcctNbr());
            TRANSQUERYBYBREAKPOINT_X1.put(aaa);
            bodyObj.put("TRANSQUERYBYBREAKPOINT_X1", TRANSQUERYBYBREAKPOINT_X1);


        /*JSONArray TRANSQUERYBYBREAKPOINT_Y1 = new JSONArray();
        JSONObject ccc = new JSONObject();
        ccc.put("dmanbr", params.getDmanbr());
        TRANSQUERYBYBREAKPOINT_Y1.add(ccc);
        bodyObj.put("TRANSQUERYBYBREAKPOINT_Y1", TRANSQUERYBYBREAKPOINT_Y1);*/


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response ASYCALHD(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "ASYCALHD";

            JSONObject bodyObj = new JSONObject();
            bodyObj.put("primod", "PDF");
            bodyObj.put("eacnbr", params.getEacnbr());
            bodyObj.put("begdat", params.getBegdat());
            bodyObj.put("enddat", params.getEnddat());
            bodyObj.put("rrcflg", params.getRrcflg());
            bodyObj.put("begamt", params.getBegamt());
            bodyObj.put("endamt", params.getEndamt());
            bodyObj.put("rrccod", params.getRrccod());


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }

    @Override
    public Response getSubAccount(CmbMidRequest cmbMidRequest) {
        String id = cmbMidRequest.getMid();
        String systemPlatform = cmbMidRequest.getSystemPlatform();
        DdwxMemberSubAccountDTO subAccountDTO = ddwxMemberSubAccountService.findByMId(id, systemPlatform);
        String cmbAccount = "";
        if (subAccountDTO == null) { //生成子账号
            cmbAccount = getRandomNum(7, ddwxMemberSubAccountService::getCountByAccount);
            subAccountDTO = new DdwxMemberSubAccountDTO();
            subAccountDTO.setMid(id);
            subAccountDTO.setSystemPlatform(cmbMidRequest.getSystemPlatform());
            subAccountDTO.setNotifyUrl(cmbMidRequest.getNotifyUrl());
            subAccountDTO.setSubAccount(cmbAccount);
            // bug修复 （int）System.currentTimeMillis()   有可能得到负数的值
            //subAccountDTO.setCreateTime((int) System.currentTimeMillis());
            //subAccountDTO.setCreateTime(Integer.parseInt(String.valueOf(System.currentTimeMillis())));
            subAccountDTO.setCreateTime(Integer.parseInt(String.valueOf(System.currentTimeMillis()/1000)));
            ddwxMemberSubAccountService.addSubAccount(subAccountDTO);
        }
        return new Response().data(subAccountDTO);
    }


    @Override
    public Response getSubAccountMid(CmbSubAccountRequest cmbSubAccountRequest) {
        String subAccount = cmbSubAccountRequest.getSubAccount();
        String systemPlatform = cmbSubAccountRequest.getSystemPlatform();
        DdwxMemberSubAccountDTO subAccountDTO = ddwxMemberSubAccountService.queryBySubAccounts(subAccount, systemPlatform);
        return new Response().data(subAccountDTO);
    }

    @Override
    public Response NTDMTQRY(CmbPayParams params) {
        try {
            // 业务接口名，这里是查询业务模式接口，生产请替换为对应接口名
            String funcode = "NTDMTQRY";

            JSONObject bodyObj = new JSONObject();
            JSONArray ntdmtqryy1 = new JSONArray();
            JSONObject aaa = new JSONObject();
            aaa.put("bbknbr", params.getBbknbr());
            aaa.put("inbacc", params.getInbacc());
            aaa.put("dyanbr", params.getDyanbr());
            aaa.put("begdat", params.getBegdat());
            aaa.put("enddat", params.getEnddat());
            aaa.put("ctnkey", params.getCtnkey());
            ntdmtqryy1.put(aaa);
            bodyObj.put("ntdmtqryy1", ntdmtqryy1);


            DcHelper dchelper = new DcHelper(cmbPayBean.getUrl(), cmbPayBean.getUid(), cmbPayBean.getPrivateKey(), cmbPayBean.getPublicKey(), cmbPayBean.getSymKey());
            String resposeStr = dchelper.sendRequest(GenerateRequestBody(bodyObj, funcode), funcode);
            //JSONObject respose = JSONObject.parseObject(resposeStr).getJSONObject("response");
            JSONObject respose = JsonUtils.convertValue(resposeStr, JSONObject.class).getJSONObject("response");
            JSONObject body = respose.getJSONObject("body");
            JSONObject head = respose.getJSONObject("head");
            if (!head.isNull("resultcode") && head.getString("resultcode").equals("SUC0000")) {
                return new Response().data(body.toString());
            } else {
                return new Response().data(head.getString("resultmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return new Response().failure(e.getMessage());
        }
    }


    /**
     * 识别子账号对应会员信息 subAccounts
     * 给对应会员余额进行充值  amount
     * 新增一条会员的余额充值记录
     * 并相应生成对应的订单总信息&充值订单信息
     *
     * @param subAccounts
     * @param amount
     */
    @Transactional
    public void addRecharge(String subAccounts, String amount) {
        /**
         * Transaction Manager (7 people, payment recognition)
         * China Merchants Bank Collection
         * System balance recharge
         * Add money
         * Identify member information corresponding to sub accounts
         * Recharge the corresponding member's balance
         * Add a balance recharge record for a new member
         * And generate corresponding order total information and recharge order information accordingly
         */
        /*DdwxMemberSubAccountDTO ddwxMemberSubAccountDTO = ddwxMemberSubAccountService.queryBySubAccounts(subAccounts);
        String mid = ddwxMemberSubAccountDTO.getMid();
        DdwxMemberDTO ddwxMemberDTO = ddwxMemberService.findById(Long.valueOf(mid));

        //新增订单记录
        DdwxPayOrderDTO ddwxPayOrderDTO = ddwxPayOrderService.addCmbRechargeRecord(ddwxMemberDTO, amount);

        //新增充值订单
        DdwxRechargeOrderDTO ddwxRechargeOrderDTO = ddwxRechargeOrderService.addCmbRechargeRecord(ddwxMemberDTO, ddwxPayOrderDTO, amount);

        //回填充值订单主键id至订单记录表
        ddwxPayOrderService.updateOrderId(ddwxPayOrderDTO,ddwxRechargeOrderDTO);
        //新增充值记录
        ddwxMemberMoneyLogService.addCmbRechargeRecord(ddwxMemberDTO,ddwxPayOrderDTO,ddwxRechargeOrderDTO,amount);

        //会员余额新增充值
        ddwxMemberService.updateBalanceByCmbRecharge(ddwxMemberDTO,amount);*/
    }


}
